<%@page import="com.xiaolin.sports.model.CourseInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>课程详情</title>
</head>
<body id="bmBody">
	<jsp:include page="/WEB-INF/page/common/_header.jsp" />
	<div class="pic-list bgfff">
			<ul class="clearfix">
				<li class="clearfix">
					<a href="#">
						<div class="pic-list-l">
							<img src="${config.imgUrl }${course.courseImg }" alt="" />
						</div>
						<div class="pic-list-r">
							<p class="pic-list-title">
								${course.courseName }
							</p>
							<p class="kcbDetail-priceLine" style="padding: 10px 0 0;">价格：<span class="bmf-top-priceWrap">￥<span class="bmf-top-price">${course.currentPrice }</span></span></p>
						</div>
					</a>
				</li>
			</ul>
		</div>
		<div class="sign-title">我要报名</div>
		<div id="accountBind" class="userCenter-list2">
			<form id="courseSignForm">
				<input type="hidden" id="productId" name="productId" value="${course.id }">
				<ul class="clearfix bgfff pl25">
					<li class="clearfix">
						<span class="userCenter-list2-left">家长姓名</span>
						<input id="emerName" name="emerName" value="${parent.parentName }" type="text" placeholder="请输入家长姓名">
					</li>
					<li class="clearfix">
						<span class="userCenter-list2-left">手机号码</span>
						<input id="emerMobile" name="emerMobile" value="${parent.parentMobile }" type="text" placeholder="请输入手机号码">
					</li>
					<li class="clearfix">
						<span class="userCenter-list2-left">孩子姓名</span>
						<input id="childName" name="childName" type="text" placeholder="请输入孩子姓名">
					</li>
					<li class="clearfix">
						<span class="userCenter-list2-left">孩子身份证</span>
						<input id="childIdcard" name="childIdcard" type="text" placeholder="请正确输入，用于购买保险">
					</li>
					<li class="clearfix">
						<span class="userCenter-list2-left">性别</span>
						<div class="fl">
							<label class="checkbox checked" data-value="F">男<input name="childSex" class="none" type="radio" value="F" checked></label>
							<label class="checkbox" data-value="M">女<input name="childSex" class="none" type="radio" value="M"></label>
						</div>
					</li>
				</ul>
				<div class="btnWrap mt150 pb150">
					<span id="regMT-btn" class="btn">确定</span>
				</div>
			</form>
		</div>
	<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
	<script type="text/javascript">
		$(function(){
			$("#accountBind .checkbox").click(function(){
				$(this).addClass("checked").siblings().removeClass("checked");
			});
			$("#regMT-btn").click(function(){
				var arr = ["childName","childSex","childIdcard","emerName","emerMobile"];
				for(var i = 0, len = arr.length; i < len; i++){
					window[arr[i]] = $("#"+arr[i]).val();
				}
				
				var phoneReg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
				
				//验证姓名
				if(!/^[\u2E80-\u9FFF]+$/.test(childName)){
					if(childName == '') alert('请填写姓名');
					else alert('姓名不正确');
					return false;
				}
				if(!$("input[name='childSex']:checked").val()) {
					alert('请选择性别');
					return false;
				}
				//验证身份证
				if(!idCardNo(childIdcard)){
					if(childIdcard == '') alert('请填写身份证');
					else alert('身份证不正确');
					return false;
				}
				if(!/^[\u2E80-\u9FFF]+$/.test(emerName)){
					if(emerName == '') alert('请填写紧急联系人');
					else alert('紧急联系人不正确');
					return false;
				}
				//验证手机号
				if(!phoneReg.test(emerMobile)){
					if(emerMobile == '') alert('请填写联系电话');
					else alert('联系电话不正确');
					return false;
				}
				if(payData != null) {
					onBridgeReady(payData);
					return;
				}
				var dataParams = $('#courseSignForm').serialize();
				$.ajax({
			 		url : "<%=basePath%>/course/sign/order/create",
			 		type : "post",
			 		data : dataParams,
			 		dataType : "json",
			 		async : false,
			 		success : function(data) {
			 			if(data.code == '000') {
			 				window.location.href = basePath + "/pay/detail?" + data.data;
			 			}else {
			 				alert(data.msg);
			 			}
			 		}, error:function(){
			 			alert("系统异常，请联系管理员");
	        		}
			 	});
			})
		});
	</script>
</body>
</html>